// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity;

import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.nnee.p_fk.cls_k;
import com.nnee.p_img.cls_d;
import com.nnee.p_pr.p_activity.p_view.cls_PRISGridView;
import com.nnee.p_pr.p_activity.p_view.cls_RelativeLayoutEx;
import com.nnee.p_pr.p_atom.cls_g;
import com.nnee.p_pr.p_atom.cls_u;
import com.nnee.p_pr.cls_v;
import java.util.HashMap;
import java.util.LinkedList;

// Referenced classes of package com.nnee.p_pr.p_activity:
//            aw, MainGridActivity, ax

public class cls_cr extends BaseAdapter
{

    public cls_cr(cls_MainGridActivity parammaingridactivity)
    {super();
        a = parammaingridactivity;
        
        b = new HashMap();
        c = new cls_aw(this);
    }

    private void a(View view, cls_u u1, int i, int j)
    {
        if(view == null)
            throw new RuntimeException("invalid input");
        if(cls_MainGridActivity.L(a) == null)
            cls_MainGridActivity.a(a, BitmapFactory.decodeResource(a.getResources(), 0x7f020131));
        cls_RelativeLayoutEx relativelayoutex = (cls_RelativeLayoutEx)view;
        relativelayoutex.a(cls_MainGridActivity.L(a));
        ImageView imageview = (ImageView)view.findViewById(0x7f0d00a4);
        ImageView imageview1 = (ImageView)view.findViewById(0x7f0d00a5);
        TextView textview = (TextView)view.findViewById(0x7f0d00a6);
        a(relativelayoutex, imageview, imageview1, textview);
        if(u1.V().equals("-1"))
        {
            textview.setVisibility(8);
            imageview1.setVisibility(8);
            imageview.setTag(null);
            imageview.setScaleType(android.widget.ImageView.ScaleType.CENTER);
            imageview.setImageDrawable(cls_k.a(a).b(0x7f020004));
            imageview.setBackgroundColor(cls_k.a(a).c(0x7f0800f0));
            cls_MainGridActivity.a(a, imageview);
            relativelayoutex.a(false);
            relativelayoutex.invalidate();
        } else
        {
            textview.setVisibility(0);
            imageview.setScaleType(android.widget.ImageView.ScaleType.CENTER_CROP);
            relativelayoutex.a(u1.t());
            relativelayoutex.invalidate();
            String s;
            if(cls_MainGridActivity.a(a, u1))
            {
                imageview1.setImageResource(0x7f02013f);
                imageview1.setVisibility(0);
            } else
            {
                imageview1.setImageDrawable(null);
                imageview1.setVisibility(8);
            }
            textview.setText(u1.U());
            s = u1.b(cls_g.fEConver);
            if(s == null)
            {
                imageview.setImageDrawable(null);
                imageview.setBackgroundColor(Color.rgb(225, 225, 225));
            } else
            {
                int l = a.c();
                int i1 = a.b();
                android.graphics.Bitmap bitmap = cls_d.a().a(s, 2, l, i1);
                if(bitmap != null)
                {
                    imageview.setImageBitmap(bitmap);
                } else
                {
                    String s1 = u1.y();
                    android.graphics.Bitmap bitmap1 = cls_d.a().a(s1, 2, a.c(), a.b());
                    StringBuilder stringbuilder;
                    if(bitmap1 != null)
                        imageview.setImageBitmap(bitmap1);
                    else
                        imageview.setImageDrawable(null);
                    stringbuilder = new StringBuilder();
                    imageview.setTag(stringbuilder);
                    cls_d.a().a(stringbuilder, 2, s, new cls_ax(this, imageview), l, i1, j, i);
                }
            }
        }
    }

    private void a(cls_RelativeLayoutEx relativelayoutex, ImageView imageview, ImageView imageview1, TextView textview)
    {
        if(relativelayoutex != null)
            relativelayoutex.a(false);
        if(imageview != null)
        {
            imageview.setImageDrawable(null);
            imageview.setBackgroundDrawable(null);
        }
        if(imageview1 != null)
        {
            imageview1.setImageDrawable(null);
            imageview1.setBackgroundDrawable(null);
        }
        if(textview != null)
            textview.setText("");
    }

    public int a()
    {
        return cls_MainGridActivity.c(a).size();
    }

    public int a(int i)
    {
        if(i < 0 || i >= getCount())
            throw new RuntimeException("invalid position");
        Integer integer = (Integer)b.get(Integer.valueOf(i));
        if(integer == null)
        {
            int j = cls_v.b();
            b.put(Integer.valueOf(i), Integer.valueOf(j));
            integer = Integer.valueOf(j);
        }
        return integer.intValue();
    }

    public int a(cls_u u1)
    {
        int i;
        if(u1 == null || cls_MainGridActivity.c(a) == null)
            i = -1;
        else
            i = cls_MainGridActivity.c(a).indexOf(u1);
        return i;
    }

    public View a(int i, ViewGroup viewgroup, View view, int j, int l)
    {
        cls_u u1 = (cls_u)getItem(i);
        if(u1 == null)
            throw new RuntimeException((new StringBuilder()).append("entry got at position: ").append(i).append(" is null!").toString());
        if(view == null || view.getTag() == null || !cls_MainGridActivity.K(a) || !((String)view.getTag()).equals(u1.V()))
        {
            if(view == null)
                view = a.getLayoutInflater().inflate(0x7f030032, null);
            a(view, u1, j, l);
            view.setTag(u1.V());
        }
        return view;
    }

    public void a(int i, String s, View view)
    {
        if(view != null && i >= 0 && i < a() && !TextUtils.isEmpty(s)){
        	Object obj = getItem(i);
            if(obj != null)
            {
                cls_u u1 = (cls_u)obj;
                if(view instanceof cls_RelativeLayoutEx)
                    ((cls_RelativeLayoutEx)view).a(u1.t());
            }
        }
    }

    public int getCount()
    {
        int i;
        if(cls_MainGridActivity.c(a).size() % 6 > 0)
            i = 1 + cls_MainGridActivity.c(a).size() / 6;
        else
            i = cls_MainGridActivity.c(a).size() / 6;
        return i;
    }

    public Object getItem(int i)
    {
        return cls_MainGridActivity.c(a).get(i);
    }

    public long getItemId(int i)
    {
        return (long)i;
    }

    public View getView(int i, View view, ViewGroup viewgroup)
    {
        cls_PRISGridView prisgridview1;
        if(view == null || !(view instanceof cls_PRISGridView))
        {
            cls_PRISGridView prisgridview = (cls_PRISGridView)a.getLayoutInflater().inflate(0x7f03000a, null);
            prisgridview.a(this);
            prisgridview.a(8);
            prisgridview.b(8);
            prisgridview.a(c);
            prisgridview.a(a.A);
            prisgridview.a(cls_MainGridActivity.J(a));
            prisgridview1 = prisgridview;
        } else
        {
            prisgridview1 = (cls_PRISGridView)view;
        }
        prisgridview1.d(i);
        return prisgridview1;
    }

    final cls_MainGridActivity a;
    private HashMap b;
    private com.nnee.p_pr.p_activity.p_view.cls_d c;
}
